/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Catarina
 */
public class Galovs3 extends javax.swing.JFrame {
    public String playerName;
    public String simbolo ="X";
    /**
     * Creates new form Galovs3
     */
    public Galovs3() {
        initComponents();  
        this.setLocationRelativeTo(null); 
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        janelaJogo = new javax.swing.JFrame();
        title1 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        state1 = new javax.swing.JPanel();
        lbstate = new javax.swing.JLabel();
        board1 = new javax.swing.JPanel();
        bt1 = new javax.swing.JButton();
        bt2 = new javax.swing.JButton();
        bt3 = new javax.swing.JButton();
        bt4 = new javax.swing.JButton();
        bt5 = new javax.swing.JButton();
        bt6 = new javax.swing.JButton();
        bt7 = new javax.swing.JButton();
        bt8 = new javax.swing.JButton();
        bt9 = new javax.swing.JButton();
        menu = new javax.swing.JFrame();
        btCreateGame1 = new javax.swing.JButton();
        btJoinGame1 = new javax.swing.JButton();
        lbWelcome1 = new javax.swing.JLabel();
        lbPlayerName1 = new javax.swing.JLabel();
        btOk1 = new javax.swing.JButton();
        jtextPlayerName1 = new javax.swing.JTextField();
        btCancel1 = new javax.swing.JButton();
        labelPlayerName1 = new javax.swing.JLabel();

        janelaJogo.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        janelaJogo.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        janelaJogo.setForeground(java.awt.Color.white);
        janelaJogo.setMaximumSize(new java.awt.Dimension(250, 275));
        janelaJogo.setMinimumSize(new java.awt.Dimension(250, 275));
        janelaJogo.setName("base"); // NOI18N
        janelaJogo.setPreferredSize(new java.awt.Dimension(250, 275));
        janelaJogo.setResizable(false);

        title1.setMaximumSize(new java.awt.Dimension(200, 50));
        title1.setMinimumSize(new java.awt.Dimension(200, 50));
        title1.setName(""); // NOI18N

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel6.setText("Jogo do Galo");

        javax.swing.GroupLayout title1Layout = new javax.swing.GroupLayout(title1);
        title1.setLayout(title1Layout);
        title1Layout.setHorizontalGroup(
            title1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, title1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
                .addContainerGap())
        );
        title1Layout.setVerticalGroup(
            title1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(title1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        state1.setMaximumSize(new java.awt.Dimension(200, 25));
        state1.setMinimumSize(new java.awt.Dimension(200, 25));
        state1.setName(""); // NOI18N
        state1.setPreferredSize(new java.awt.Dimension(200, 25));

        lbstate.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbstate.setText("...");

        javax.swing.GroupLayout state1Layout = new javax.swing.GroupLayout(state1);
        state1.setLayout(state1Layout);
        state1Layout.setHorizontalGroup(
            state1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lbstate, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
        );
        state1Layout.setVerticalGroup(
            state1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lbstate, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
        );

        board1.setBackground(new java.awt.Color(51, 51, 51));
        board1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        board1.setMaximumSize(new java.awt.Dimension(200, 185));
        board1.setMinimumSize(new java.awt.Dimension(200, 185));
        board1.setName("board1"); // NOI18N
        board1.setPreferredSize(new java.awt.Dimension(200, 185));
        board1.setLayout(new java.awt.GridLayout(3, 3));

        bt1.setMaximumSize(new java.awt.Dimension(33, 4));
        bt1.setMinimumSize(new java.awt.Dimension(33, 4));
        bt1.setName("b1"); // NOI18N
        bt1.setPreferredSize(new java.awt.Dimension(33, 4));
        bt1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt1ActionPerformed(evt);
            }
        });
        board1.add(bt1);

        bt2.setName("b2"); // NOI18N
        bt2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt2ActionPerformed(evt);
            }
        });
        board1.add(bt2);

        bt3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt3ActionPerformed(evt);
            }
        });
        board1.add(bt3);

        bt4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt4ActionPerformed(evt);
            }
        });
        board1.add(bt4);

        bt5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt5ActionPerformed(evt);
            }
        });
        board1.add(bt5);

        bt6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt6ActionPerformed(evt);
            }
        });
        board1.add(bt6);

        bt7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt7ActionPerformed(evt);
            }
        });
        board1.add(bt7);

        bt8.setToolTipText("");
        bt8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt8ActionPerformed(evt);
            }
        });
        board1.add(bt8);

        bt9.setActionCommand("");
        bt9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt9ActionPerformed(evt);
            }
        });
        board1.add(bt9);

        javax.swing.GroupLayout janelaJogoLayout = new javax.swing.GroupLayout(janelaJogo.getContentPane());
        janelaJogo.getContentPane().setLayout(janelaJogoLayout);
        janelaJogoLayout.setHorizontalGroup(
            janelaJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(title1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(state1, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
            .addGroup(janelaJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, janelaJogoLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(board1, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
                    .addContainerGap()))
        );
        janelaJogoLayout.setVerticalGroup(
            janelaJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(janelaJogoLayout.createSequentialGroup()
                .addComponent(title1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 200, Short.MAX_VALUE)
                .addComponent(state1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(janelaJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, janelaJogoLayout.createSequentialGroup()
                    .addContainerGap(45, Short.MAX_VALUE)
                    .addComponent(board1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(45, Short.MAX_VALUE)))
        );

        menu.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        menu.setMaximumSize(new java.awt.Dimension(250, 275));
        menu.setMinimumSize(new java.awt.Dimension(250, 275));
        menu.setResizable(false);

        btCreateGame1.setText("CREATE GAME");
        btCreateGame1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCreateGame1ActionPerformed(evt);
            }
        });

        btJoinGame1.setText("JOIN GAME");

        lbWelcome1.setText("WELCOME, ");

        lbPlayerName1.setText("PLAYER_NAME");

        javax.swing.GroupLayout menuLayout = new javax.swing.GroupLayout(menu.getContentPane());
        menu.getContentPane().setLayout(menuLayout);
        menuLayout.setHorizontalGroup(
            menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, menuLayout.createSequentialGroup()
                .addContainerGap(61, Short.MAX_VALUE)
                .addGroup(menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(menuLayout.createSequentialGroup()
                        .addComponent(lbWelcome1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbPlayerName1))
                    .addGroup(menuLayout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(btCreateGame1))
                    .addGroup(menuLayout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addComponent(btJoinGame1)))
                .addGap(55, 55, 55))
        );
        menuLayout.setVerticalGroup(
            menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(menuLayout.createSequentialGroup()
                .addGap(82, 82, 82)
                .addGroup(menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbWelcome1)
                    .addComponent(lbPlayerName1))
                .addGap(31, 31, 31)
                .addComponent(btCreateGame1)
                .addGap(18, 18, 18)
                .addComponent(btJoinGame1)
                .addContainerGap(84, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMaximumSize(new java.awt.Dimension(250, 100));
        setMinimumSize(new java.awt.Dimension(250, 100));
        setResizable(false);

        btOk1.setText("Ok");
        btOk1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btOk1ActionPerformed(evt);
            }
        });

        btCancel1.setText("Cancel");
        btCancel1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancel1ActionPerformed(evt);
            }
        });

        labelPlayerName1.setText("Player Name:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(labelPlayerName1)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jtextPlayerName1)
                        .addContainerGap())))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(124, Short.MAX_VALUE)
                .addComponent(btOk1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btCancel1)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelPlayerName1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtextPlayerName1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btOk1)
                    .addComponent(btCancel1))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bt1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt1ActionPerformed
        if (!bt1.getText().equals("")) {
            bt1.setText(simbolo);
        }     
            
    }//GEN-LAST:event_bt1ActionPerformed

    private void bt6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt6ActionPerformed
       if (!bt6.getText().equals("")) {
            bt6.setText(simbolo);
        }
    }//GEN-LAST:event_bt6ActionPerformed

    private void btCreateGame1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCreateGame1ActionPerformed
    	janelaJogo.setLocationRelativeTo(null); 
    	janelaJogo.setVisible(true);
        menu.setVisible(false);
        lbstate.setText("E a vez do/a jogador/a " +  playerName + " jogar.");
    }//GEN-LAST:event_btCreateGame1ActionPerformed

    private void btOk1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOk1ActionPerformed
        playerName=jtextPlayerName1.getText();
        menu.setLocationRelativeTo(null); 
        menu.setVisible(true);
        lbPlayerName1.setText(playerName);
        this.setVisible(false);
    }//GEN-LAST:event_btOk1ActionPerformed

    private void btCancel1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancel1ActionPerformed
       
    }//GEN-LAST:event_btCancel1ActionPerformed

    private void bt2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt2ActionPerformed
        if (!bt2.getText().equals("")) {
            bt2.setText(simbolo);
        }
    }//GEN-LAST:event_bt2ActionPerformed

    private void bt3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt3ActionPerformed
        if (!bt3.getText().equals("")) {
            bt3.setText(simbolo);
        }       
    }//GEN-LAST:event_bt3ActionPerformed

    private void bt4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt4ActionPerformed
        if (!bt4.getText().equals("")) {
            bt4.setText(simbolo);
        }    
    }//GEN-LAST:event_bt4ActionPerformed

    private void bt5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt5ActionPerformed
         if (!bt5.getText().equals("")) {
            bt5.setText(simbolo);
        }
    }//GEN-LAST:event_bt5ActionPerformed

    private void bt7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt7ActionPerformed
        if (!bt7.getText().equals("")) {
            bt7.setText(simbolo);
        }
    }//GEN-LAST:event_bt7ActionPerformed

    private void bt8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt8ActionPerformed
        if (!bt8.getText().equals("")) {
            bt8.setText(simbolo);
        }
    }//GEN-LAST:event_bt8ActionPerformed

    private void bt9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt9ActionPerformed
         if (!bt9.getText().equals("")) {
            bt9.setText(simbolo);
        }
    }//GEN-LAST:event_bt9ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Galovs3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Galovs3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Galovs3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Galovs3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Galovs3().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel board1;
    private javax.swing.JButton bt1;
    private javax.swing.JButton bt2;
    private javax.swing.JButton bt3;
    private javax.swing.JButton bt4;
    private javax.swing.JButton bt5;
    private javax.swing.JButton bt6;
    private javax.swing.JButton bt7;
    private javax.swing.JButton bt8;
    private javax.swing.JButton bt9;
    private javax.swing.JButton btCancel1;
    private javax.swing.JButton btCreateGame1;
    private javax.swing.JButton btJoinGame1;
    private javax.swing.JButton btOk1;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JFrame janelaJogo;
    private javax.swing.JTextField jtextPlayerName1;
    private javax.swing.JLabel labelPlayerName1;
    private javax.swing.JLabel lbPlayerName1;
    private javax.swing.JLabel lbWelcome1;
    private javax.swing.JLabel lbstate;
    private javax.swing.JFrame menu;
    private javax.swing.JPanel state1;
    private javax.swing.JPanel title1;
    // End of variables declaration//GEN-END:variables
}
